package com.jmu.Shape;

import com.jmu.Shape.Rectangle;

import java.util.ArrayList;

public class TestShape {
    public static void main(String[] args) {
        //长方形
        Shape rectangle = new Rectangle(2, 3);
        //三角形
        Shape triangle = new Triangle(3,4,5);
        //圆形
        Shape circle = new Circle(2);

        //创建范形数组 并添加对象
        ArrayList<Shape> arrayList = new ArrayList();
        arrayList.add(rectangle);
        arrayList.add(triangle);
        arrayList.add(circle);

        //输出对象的周长以及面积
        for (Shape shape:arrayList
             ) {
            System.out.println("面积为：" + shape.getArea() + " 周长为：" + shape.getPerimeter());
        }
    }
}
